<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      .button {
        margin: 0 auto;
        text-align: center;
      }

      .box {
        border: 1px solid blue;
        width: 80px;
        margin: 15px auto;
        text-align: center;
        line-height: 30px;
        display: none;
      }
      /* .btn:hover{
       background-color:red;
      } */
    </style>
  </head>
  <body>
    <div class="button">
      <button>输入法</button>
      <div class="box">
        <div class="btn">手写</div>
        <div class="btn">拼音</div>
        <div class="btn btn1">关闭</div>
      </div>
    </div>
  </body>
</html>
<script>
  let num = 1;
  let box = document.querySelector(".box");
  let btn = document.querySelectorAll(".btn");
  let button = document.querySelector("button");
  let btn1 = document.querySelector(".btn1");
  button.onclick = function () {
    // console.log(1)
    if (num == 1) {
      box.style.display = "block";
      num++;
    } else {
      box.style.display = "none";
      num = 1;
    }
  };
  for (let i = 0; i < btn.length; i++) {
    btn[i].onmouseover = function () {
      btn[i].style.background = "blue";
    };
  }
  for (let i = 0; i < btn.length; i++) {
    btn[i].onmouseout = function () {
      btn[i].style.background = "none";
    };
  }
  btn1.onclick = function () {
    box.style.display = "none";
    num = 1;
  };
</script>
